//
//  LKWorkOrderListCell.m
//  YLHelper
//
//  Created by she1323 on 2018/4/16.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKWorkOrderListCell.h"

@interface LKWorkOrderListCell()

@property (weak, nonatomic) IBOutlet UIView *bgview;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *editSWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *deletWidth;
@property (weak, nonatomic) IBOutlet UILabel *approvalLabel;

@end

@implementation LKWorkOrderListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.deleteBtn.layer.borderColor = COLOR_HEX(0x929292).CGColor;
    self.deleteBtn.layer.borderWidth = 1;
    self.deleteBtn.layer.cornerRadius = 5;
    self.deleteBtn.layer.masksToBounds = YES;
    self.editBtn.layer.borderColor = COLOR_HEX(0x4A78E8).CGColor;
    self.editBtn.layer.borderWidth = 1;
    self.editBtn.layer.cornerRadius = 5;
    self.editBtn.layer.masksToBounds = YES;
    _editSWidth.constant = WIDTH * 0.146 ;
    _deletWidth.constant = WIDTH * 0.146 ;
    self.labelsView = [[LKWorkLabelView alloc] initWithFrame:self.bgview.bounds];
//    _labelsView.titleArray = @[@"客户姓名：刘德华",@"产品名称：供应链银来项目-1011期",@"产品期限：6个月",@"年化收益：10%",@"投资金额：1000000.00",@"起息日期：2018-04-19"];
    [self.bgview addSubview:_labelsView];
    // Initialization code
}

-(void)setModel:(LKOrderModel *)model{
    self.deleteBtn.hidden = YES;
    self.editBtn.hidden = YES;
    _model = model;
    self.approvalLabel.text = _model.approvalStatusS;
    NSString *customerName = [NSString stringWithFormat:@"%@%@",@"客户姓名：",_model.customerName];
    NSString *productName = [NSString stringWithFormat:@"%@%@",@"产品名称：",_model.productName];
    NSString *productTime = [NSString stringWithFormat:@"%@%@",@"产品期限：",_model.productTerm];
    NSString *nianshouyi = [NSString stringWithFormat:@"%@%@",@"年化收益：",_model.productAnnualizedYield];
    NSString *investMoney = [NSString stringWithFormat:@"%@%@",@"投资金额：",_model.investmentAmount];
    NSString *timeToTime = [NSString stringWithFormat:@"%@%@",@"起息日期：",[[_model.calulationDate componentsSeparatedByString:@"T"] firstObject]];
    _labelsView.titleArray = @[customerName,productName,productTime,nianshouyi,investMoney,timeToTime];
    _headerLabel.text = [NSString stringWithFormat:@"%@%@",@"合同编号：",_model.contractCode];
    NSMutableArray *eidtArra = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < _model.orderInfoButtonType.count; i++) {
        NSString *values = [NSString stringWithFormat:@"%@",_model.orderInfoButtonType[i]];
        [eidtArra addObject:values];
    }
    for (NSString *valus in eidtArra) {
        if ([valus isEqual:@"0"]) {
            self.editBtn.hidden = NO;
            [self.editBtn setTitle:@"编辑" forState:UIControlStateNormal];
        }
        if ([valus isEqual:@"1"]) {
            self.editBtn.hidden = NO;
            [self.editBtn setTitle:@"变更" forState:UIControlStateNormal];
        }
        if ([valus isEqual:@"-1"]) {
            self.deleteBtn.hidden = NO;
        }
        if ([valus isEqual:@"2"]) {
            self.editBtn.hidden = NO;
        }
    }
//    if ([_model.approvalStatus integerValue] == 4 || [_model.approvalStatus integerValue] == 7 || [_model.approvalStatus integerValue] == -6 || [_model.approvalStatus integerValue] == 6) {
//        [self.editBtn setTitle:@"变更" forState:UIControlStateNormal];
//    }else{
//        [self.editBtn setTitle:@"编辑" forState:UIControlStateNormal];
//    }
//    if ([_model.approvalStatus integerValue] != 0) {
//        self.deleteBtn.hidden = YES;
//        if ([_model.approvalStatus integerValue] == 1 || [_model.approvalStatus integerValue] == 6 || [_model.approvalStatus integerValue] == 2 || [_model.approvalStatus integerValue] == 3 || [_model.approvalStatus integerValue] == 8 || [_model.approvalStatus integerValue] == 9 || [_model.approvalStatus integerValue] == -8) {
//            self.editBtn.hidden = YES;
//        }else{
//            self.editBtn.hidden = NO;
//        }
//    }else{
//        self.deleteBtn.hidden = NO;
//        self.editBtn.hidden = NO;
//    }
    [_labelsView.tableview reloadData];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
